{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1aba7452",
   "metadata": {},
   "source": [
    "_________\n",
    "* 日期：2022-09-07\n",
    "* 课程：python\n",
    "* 记录人:吴粤\n",
    "_________\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0d3ce305",
   "metadata": {},
   "source": [
    "# 本周学习内容 #\n",
    "> 1. 变量\n",
    ">> 1. 变量的定义与声明\n",
    ">> 2. 变量名的一般规则\n",
    "> 2. 编程的控制流\n",
    ">> 1. 条件判断\n",
    ">> 2. 循环遍历"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b031a7ae",
   "metadata": {},
   "source": [
    "## 1.变量学习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c2d7b431",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_01_ID = \"2200000001\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b73c1989",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "网三_01_ID\n"
     ]
    }
   ],
   "source": [
    "print('网三_01_ID')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "262d7028",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2200000001'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_01_ID"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "1f239d0a",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_01_name = \"小白\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "5fd07fa1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'小白'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_01_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "72420d6d",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_01_ID=\"230000001\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "67cb5b18",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'230000001'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_01_ID"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "eb7458d9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "小白 小白\n",
      "Alex 小白\n"
     ]
    }
   ],
   "source": [
    "网三_01_name = \"小白\"\n",
    "\n",
    "网三_02_name = 网三_01_name\n",
    "\n",
    "print(网三_01_name,网三_02_name)\n",
    "\n",
    "网三_01_name = \"Alex\"\n",
    "\n",
    "print(网三_01_name,网三_02_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "aec8941d",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2580178983792"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "id(网三_01_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "8b4434dd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2580178622000"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "id(网三_02_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "fae45976",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 黑客帝国（“空间”）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9d3ff769",
   "metadata": {},
   "source": [
    "## 2.条件判断"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "70fc2e61",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 课本案例 p18"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "3c5ff360",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Recover, then rest.\n"
     ]
    }
   ],
   "source": [
    "# 变量today需要先赋值\n",
    "today = \"Sunday\"\n",
    "condition = \"Headache\"\n",
    "\n",
    "\n",
    "\n",
    "if today == \"Saturday\":\n",
    "    print(\"Party!\")\n",
    "elif today == \"Sunday\":\n",
    "    if condition == \"Headache\":\n",
    "        print(\"Recover, then rest.\")\n",
    "    else:\n",
    "        print(\"Rest.\")\n",
    "else:\n",
    "    print(\"Work, work, work.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "41a0454b",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 练习题： 判断今天是否有Python课 （time.localtime()） ,然后如果今天有Python课，在判断现在是否是Python课ing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "7ba0aa1f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=9, tm_mday=9, tm_hour=0, tm_min=24, tm_sec=51, tm_wday=4, tm_yday=252, tm_isdst=0)"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "\n",
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "5e660fcc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4\n",
      "0\n",
      "25\n",
      "怎么还没到周三呢，哎，等的着急\n"
     ]
    }
   ],
   "source": [
    "# 创建week_day变量,time_hour变量，time_min变量\n",
    "week_day = time.localtime().tm_wday\n",
    "print(week_day)\n",
    "\n",
    "time_hour = time.localtime().tm_hour\n",
    "print(time_hour)\n",
    "\n",
    "time_min = time.localtime().tm_min\n",
    "print(time_min)\n",
    "\n",
    "if week_day == 2:\n",
    "    print(\"今天有Python课，好开心呀\")\n",
    "    if time_hour == 19:\n",
    "        print(\"Python课ing，刚上课\")\n",
    "    elif time_hour == 18 and time_min > 44:\n",
    "        print(\"Python课ing，现在在第二节课\")\n",
    "    elif time_hour == 20 and time_min < 51:\n",
    "        print(\"Python课ing,现在是第三节课了\")\n",
    "    elif time_hour< 18:\n",
    "        print(\"期待今天的课\")\n",
    "    else:\n",
    "        print(\"今天的Python课很不错\")\n",
    "else:\n",
    "    print(\"怎么还没到周三呢，哎，等的着急\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "09ad4c64",
   "metadata": {},
   "outputs": [],
   "source": [
    "# help(time)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c6e0c1c4",
   "metadata": {},
   "source": [
    "## 3. 循环遍历\n",
    "\n",
    ">1. or循环\n",
    ">2. range()方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "82fb2797",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# 用例1\n",
    "for i in [1,2,3,4]:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "53016bb9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "H\n",
      "i\n",
      "!\n",
      " \n",
      "H\n",
      "e\n",
      "l\n",
      "l\n",
      "o\n"
     ]
    }
   ],
   "source": [
    "# 用例2\n",
    "for ch in \"Hi! Hello\":\n",
    "    print(ch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "2b5593a6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# range 可以创建数组\n",
    "# 用例3 默认从 0 开始的（start） ，5是终点（stop） 默认步长（step） 1 \n",
    "for num in range(5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f34eaa45",
   "metadata": {},
   "source": [
    "## 4. 关于强大的range()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "c06b95dc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# 用例3 扩展1： 起点为 1   （可以设置起点）\n",
    "for num in range(1,5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "8f4d2171",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "3\n",
      "5\n",
      "7\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "# 用例3 扩展2 起点为1  终点为 10   步长step  2\n",
    "for num in range(1,10,2):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "8b822a44",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "210000001\n",
      "210000004\n",
      "210000007\n",
      "210000010\n",
      "210000013\n",
      "210000016\n",
      "210000019\n",
      "210000022\n",
      "210000025\n",
      "210000028\n",
      "210000031\n",
      "210000034\n",
      "210000037\n",
      "210000040\n",
      "210000043\n",
      "210000046\n",
      "210000049\n"
     ]
    }
   ],
   "source": [
    "# 具体案例\n",
    "for num in range(210000001,210000050,3):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "a00e8c5b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "8\n",
      "6\n",
      "4\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "# 用例3 扩展3\n",
    "for num in range(10,1,-2):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "0ae09d66",
   "metadata": {},
   "outputs": [],
   "source": [
    "### 课后作业：P35 项目 和 P43项目"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
